package com.base.cn.platform.os.service.course.cou;

import com.base.cn.platform.os.entity.course.cou.Course;
import com.base.cn.platform.os.entity.course.cou.CourseCondition;
import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.course.CourseBaseService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 课程数据接口
 *
 * @author s.li
 * @create 2018-04-17-14:25
 */
@FeignClient(name = CourseBaseService.appName, configuration = FeignAuthConfig.class)
public interface CourseService extends CourseBaseService {

    /**
     * 复制课程数据
     * @param courseId 课程ID
     * @param sysUserId 管理员ID
     */
    @RequestMapping(contextPath + "/copyCourse")
    Map<String,Object> copyCourse(@RequestParam("courseId") BigDecimal courseId,
                                  @RequestParam("sysUserId") BigDecimal sysUserId);

    /**
     * 获取购买课程的用户课程列表
     * @param courseId 课程ID
     * @param currentPage 页码
     * @param pageSize 查询数量
     * @return PageInfo<CourseBuyRecord>
     */
    @RequestMapping(contextPath + "/findCourseBuyUserList")
    Map<String, Object> findCourseBuyUserList(@RequestParam("courseId") BigDecimal courseId,
                                              @RequestParam("currentPage") int currentPage,
                                              @RequestParam("pageSize") int pageSize);

    /**
     * 通过父级专业IDS，查询专业下课程列表
     *
     * @param placeKey 推荐位置
     * @param profileData 是否设置课程扩展数据
     * @return
     */
    @RequestMapping(contextPath + "/findRecommendCourseList")
    List<Map<String,Object>> findRecommendCourseList(@RequestParam(value = "placeKey") String placeKey,
                                                     @RequestParam(value = "profileData", required = false, defaultValue = "false") boolean profileData,
                                                     @RequestParam(value = "teacherData", required = false, defaultValue = "false") boolean teacherData);

    /**
     * 课程数量
     *
     * @return BigDecimal
     */
    @RequestMapping(contextPath + "/courseCount")
    BigDecimal courseCount(@RequestBody Map<String, Object> params);

    /**
     * 保存课程基本信息
     *
     * @param course 课程对象
     * @return Map<String   ,   Object>
     */
    @RequestMapping(contextPath + "/saveCourse")
    Map<String, Object> saveCourse(@RequestBody Map<String, Object> course);

    /**
     * 保存描述信息
     *
     * @param course 数据对象
     * @return Map<String   ,   Object>
     */
    @RequestMapping(contextPath + "/saveCourseInfo")
    Map<String, Object> saveCourseInfo(@RequestBody Map<String, Object> course);

    /**
     * 更新课程的学习顺序
     * @param course 课程对象
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/updateCourseStudyLimit")
    Map<String,Object> updateCourseStudyLimit(@RequestBody Map<String, Object> course);

    /**
     * 查询课程详情
     *
     * @param courseId       课程ID
     * @param userId         用户ID
     * @param onLimit        是否有限制，true没有，false有
     * @param setPuyStatus   是否设置购买状态数据
     * @param teacherData    是否设置讲师数据
     * @param subjectData    是否设置专业数据
     * @param sysUserData    是否设置创建人数据
     * @param setProfileData 是否设置扩展数据
     * @param setLiveCourseNodesData  是否设置课程直播节点数据
     * @return Course
     */
    @RequestMapping(contextPath + "/findToBuyCourseById")
    Map<String, Object> findToBuyCourseById(@RequestParam("courseId") BigDecimal courseId,
                                            @RequestParam("userId") BigDecimal userId,
                                            @RequestParam("onLimit") boolean onLimit,
                                            @RequestParam("setPuyStatus") boolean setPuyStatus,
                                            @RequestParam("teacherData") boolean teacherData,
                                            @RequestParam("subjectData") boolean subjectData,
                                            @RequestParam("sysUserData") boolean sysUserData,
                                            @RequestParam("setProfileData") boolean setProfileData,
                                            @RequestParam("setLiveCourseNodesData") boolean setLiveCourseNodesData);

    /**
     * 查询课程详情
     *
     * @param courseId             课程ID
     * @param userId               用户ID
     * @param onLimit 是否有限制，true没有，false有
     * @param setPuyStatus         是否设置购买状态数据
     * @param teacherData          是否设置讲师数据
     * @param subjectData          是否设置专业数据
     * @param sysUserData          是否设置创建人数据
     * @param setProfileData       是否设置扩展数据
     * @param setPackageCourseData 是否设置套餐数据
     * @return Course
     */
    @RequestMapping(contextPath + "/findToBuyCourseManyById")
    Course findToBuyCourseManyById(@RequestParam("courseId") BigDecimal courseId,
                                   @RequestParam("userId") BigDecimal userId,
                                   @RequestParam("onLimit") boolean onLimit,
                                   @RequestParam("setPuyStatus") boolean setPuyStatus,
                                   @RequestParam("teacherData") boolean teacherData,
                                   @RequestParam("subjectData") boolean subjectData,
                                   @RequestParam("sysUserData") boolean sysUserData,
                                   @RequestParam("setProfileData") boolean setProfileData,
                                   @RequestParam("setPackageCourseData") boolean setPackageCourseData);

    /**
     * 通过ID，查询课程对象
     *
     * @param courseId    课程ID
     * @param teacherData 是否设置讲师数据
     * @param subjectData 是否设置专业数据
     * @param sysUserData 是否设置创建人数据
     * @param profileData 是否设置扩展数据
     * @return Course
     */
    @RequestMapping(contextPath + "/findCourseById")
    Map<String, Object> findCourseById(@RequestParam("courseId") BigDecimal courseId,
                                       @RequestParam("teacherData") boolean teacherData,
                                       @RequestParam("subjectData") boolean subjectData,
                                       @RequestParam("sysUserData") boolean sysUserData,
                                       @RequestParam("profileData") boolean profileData);

    /**
     * 通过多条件，查询课程数据列表
     *
     * @param condition   课程查询条件
     * @param teacherData 是否设置讲师数据
     * @param subjectData 是否设置专业数据
     * @param sysUserData 是否设置创建人数据
     * @param profileData 是否设置课程扩展数据
     * @return List<Course>
     */
    @RequestMapping(contextPath + "/findCourseList")
    List<Map<String, Object>> findCourseList(@RequestBody Map<String, Object> condition,
                                             @RequestParam("teacherData") boolean teacherData,
                                             @RequestParam("subjectData") boolean subjectData,
                                             @RequestParam("sysUserData") boolean sysUserData,
                                             @RequestParam(value = "profileData", required = false, defaultValue = "false") boolean profileData);

    /**
     * 分页查询课程列表
     *
     * @param condition      查询条件
     * @param currentPage    页码
     * @param teacherData    是否设置讲师数据
     * @param subjectData    是否设置专业数据
     * @param sysUserData    是否设置创建人数据
     * @param setProfileData 是否设置课程数据扩展数据
     * @param setLiveCourseNodesData 是否设置课程直播节点数据
     * @return PageInfo<Course>
     */
    @RequestMapping(contextPath + "/findWebCoursePage")
    Map<String, Object> findWebCoursePage(@RequestBody(required = false) Map<String, Object> condition,
                                          @RequestParam(value = "currentPage", required = false, defaultValue = "1") int currentPage,
                                          @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize,
                                          @RequestParam(value = "teacherData", required = false, defaultValue = "false") boolean teacherData,
                                          @RequestParam(value = "subjectData", required = false, defaultValue = "false") boolean subjectData,
                                          @RequestParam(value = "sysUserData", required = false, defaultValue = "false") boolean sysUserData,
                                          @RequestParam(value = "setProfileData", required = false, defaultValue = "false") boolean setProfileData,
                                          @RequestParam(value = "setLiveCourseNodesData", required = false, defaultValue = "false") boolean setLiveCourseNodesData);

    /**
     * 分页查询课程列表
     *
     * @param condition   查询条件
     * @param currentPage 页码
     * @param teacherData 是否设置讲师数据
     * @param subjectData 是否设置专业数据
     * @param sysUserData 是否设置创建人数据
     * @return Map<String   ,   Object>
     */
    @RequestMapping(contextPath + "/findCoursePage")
    Map<String, Object> findCoursePage(@RequestBody Map<String, Object> condition,
                                       @RequestParam(value = "currentPage", required = false, defaultValue = "0") int currentPage,
                                       @RequestParam(value = "pageSize", required = false, defaultValue = "0") int pageSize,
                                       @RequestParam("teacherData") boolean teacherData,
                                       @RequestParam("subjectData") boolean subjectData,
                                       @RequestParam("sysUserData") boolean sysUserData);

    /**
     * 修改完结状态
     *
     * @param courseIds 课程ID串，多个ID以“,”隔开
     */
    @RequestMapping(contextPath + "/updateContextStatus")
    Map<String, Object> updateContextStatus(@RequestParam("courseIds") String courseIds);

    /**
     * 修改课程状态
     *
     * @param courseIds 课程ID串，多个ID以“,”隔开
     * @param status    状态，1下架，2下架，3删除
     * @return Map<String   ,   Object>
     */
    @RequestMapping(contextPath + "/updateCourseStatus")
    Map<String, Object> updateCourseStatus(@RequestParam("courseIds") String courseIds, @RequestParam("status") int status);

    /**
     * 查询课程Map
     * @param condition 查询条件
     * @return Map<BigDecimal,Course>
     */
    @RequestMapping(contextPath + "/findCourseToMap")
    Map<BigDecimal,Course> findCourseToMap(@RequestBody CourseCondition condition);


    /**
     * 通过Ids，查询课程数据列表
     *
     * @param courseIds   课程查询条件
     * @param teacherData 是否设置讲师数据
     * @param subjectData 是否设置专业数据
     * @param sysUserData 是否设置创建人数据
     * @return Map<BigDecimal   ,   Course>
     */
    @RequestMapping(contextPath + "/findCourseToMapByIds")
    Map<BigDecimal, Map<String, Object>> findCourseToMapByIds(@RequestParam("courseIds") String courseIds,
                                                              @RequestParam(value = "teacherData", required = false, defaultValue = "false") boolean teacherData,
                                                              @RequestParam(value = "subjectData", required = false, defaultValue = "false") boolean subjectData,
                                                              @RequestParam(value = "sysUserData", required = false, defaultValue = "false") boolean sysUserData);

    /**
     * 查询套餐课程详情
     *
     * @param courseId 课程ID
     * @return Course
     */
    @RequestMapping(contextPath + "/findPackageInfo")
    Map<String, Object> findPackageInfo(@RequestParam("courseId") BigDecimal courseId);

    /**
     * 根据用户ID查询已购买且在有效期内的课程列表（套餐与课程分开返回）
     *
     * @param userId      用户ID
     * @param teacherData 是否设置讲师数据
     * @param subjectData 是否设置专业数据
     * @param sysUserData 是否设置创建人数据
     * @return
     */
    @RequestMapping(contextPath + "/findCourseListByUserId")
    Map<String, Object> findCourseListByUserId(@RequestParam("userId") BigDecimal userId,
                                               @RequestParam(value = "teacherData", required = false, defaultValue = "false") boolean teacherData,
                                               @RequestParam(value = "subjectData", required = false, defaultValue = "false") boolean subjectData,
                                               @RequestParam(value = "sysUserData", required = false, defaultValue = "false") boolean sysUserData);


    /**
     * 查询H5和App课程首页的精准推荐
     * @param userId 用户ID，用于精准推荐
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/getAppH5RecommendIndex")
    Map<String,Object> getAppH5RecommendIndex(@RequestParam(value = "userId", required = false, defaultValue = "0") BigDecimal userId);

    /**
     * 查询课程详情
     *
     * @param courseId       课程ID
     * @param userId         用户ID
     * @param onLimit        是否有限制，true没有，false有
     * @param setPuyStatus   是否设置购买状态数据
     * @param teacherData    是否设置讲师数据
     * @param subjectData    是否设置专业数据
     * @param sysUserData    是否设置创建人数据
     * @param setProfileData 是否设置扩展数据
     * @param setLiveCourseNodesData  是否设置课程直播节点数据
     * @return Course
     */
    @RequestMapping(contextPath + "/guideBuyCourse")
    Map<String, Object> guideBuyCourse(@RequestParam("courseId") BigDecimal courseId,
                                       @RequestParam("userId") BigDecimal userId,
                                       @RequestParam("onLimit") boolean onLimit,
                                       @RequestParam("setPuyStatus") boolean setPuyStatus,
                                       @RequestParam("teacherData") boolean teacherData,
                                       @RequestParam("subjectData") boolean subjectData,
                                       @RequestParam("sysUserData") boolean sysUserData,
                                       @RequestParam("setProfileData") boolean setProfileData,
                                       @RequestParam("setLiveCourseNodesData") boolean setLiveCourseNodesData);

    /**
     * 查询课程总数量数据
     * @return Map<String,Integer>
     */
    @RequestMapping(contextPath + "/queryCourseSumCount")
    Map<String,Integer> queryCourseSumCount();


    /**
     * 分页查询课程随堂练习列表
     *
     * @param condition   查询条件
     * @param currentPage 页码
     * @return Map<String   ,   Object>
     */
    @RequestMapping(contextPath + "/findCoursePracticePage")
    Map<String, Object> findCoursePracticePage(@RequestBody Map<String, Object> condition,
                                       @RequestParam(value = "currentPage", required = false, defaultValue = "0") int currentPage,
                                       @RequestParam(value = "pageSize", required = false, defaultValue = "0") int pageSize);


    /**
     * 查询课程详情
     * @return Course
     */
    @RequestMapping(contextPath + "/findByIdCourse")
    Course findByIdCourse(@RequestParam("courseId") BigDecimal courseId);


    /**
     * 计算从
     * @param courseId
     * @return
     */
    @RequestMapping(contextPath + "/durationSum")
    Map<String, Object> durationSum(@RequestParam("courseId") BigDecimal courseId);

    /**
     * 修改课程分销推广状态
     * @param dataKey dataKey
     * @param courseId 课程id
     * @param allow  状态 1 不可分销  2  开启分销
     * @return
     */
    @RequestMapping(contextPath+"/updateCourseAllow")
    Map<String, Object> updateCourseAllow(@RequestParam("courseId")BigDecimal courseId,@RequestParam("allow")Integer allow);
}
